

$(function() {
    validateRule();
	$('.imgcode').click(function() {
		var url = ctx + "captcha/writeImage?s=" + Math.random();
		$(".imgcode").attr("src", url);
	});
	
	$("#tenantCode").select2();
	
	$('body', document).on('keyup', function(e) {
	    if (e.which === 13) {
	        $("#btnSubmit").click();
	    }
	});
});

$.validator.setDefaults({
    submitHandler: function(form) {
    	$.modal.loading($("#btnSubmit").data("loading"));
    	form.submit();
    }
});

function validateRule() {
    var icon = "<i class='fa fa-times-circle'></i> ";
    $("#signupForm").validate({
        rules: {
        	verifyCode:{
        		required:true
        	},
        	userName: {
                required: true
            },
            passwd: {
                required: true
            }
        },
        messages: {
        	userName: {
                required: icon + "请输入您的用户名",
            },
            verifyCode: {
                required: icon + "请输入验证码",
            },
            passwd: {
                required: icon + "请输入您的密码",
            }
        }
    })
}
